package com.sicheng.lc.周赛.分类.哈西表or计数or滑动窗口or双指针;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/29 13:39
 */
public class 使两字符串互为字母异位词的最少步骤数 {
    //https://leetcode.cn/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii/
    public int minSteps(String s, String t) {

        int[] countS = new int[26];
        int[] countT = new int[26];


        for (int i = 0; i < s.length(); i++) {
            countS[s.charAt(i) - 'a']++;
        }

        for (int i = 0; i < t.length(); i++) {
            countT[t.charAt(i) - 'a']++;
        }

        int res = 0;
        for (int i = 0; i <= countS.length; i++) {
            res += Math.abs(countS[i] - countT[i]);
        }

        return res;
    }
}
